package com.tiankun.eurekaticket.service.impl;

import com.tiankun.eurekaticket.mapper.GetMapper;
import com.tiankun.eurekaticket.pojo.Get;
import com.tiankun.eurekaticket.service.GetService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author liaopeng
 * @Date 2020/11/14 15:58
 * @Version 1.0
 **/
@Service("getService")
public class GetServiceImpl implements GetService {

    @Resource
    GetMapper getMapper;

    @Override
    public Integer insert(Get get) {
        get.setGetDate(new Date());
        get.setState(0);
        return getMapper.insertSelective(get);
    }

    @Override
    public Integer updatestate(Integer id,String phone,Integer usestate) {
        Get get = new Get();
        get.setId(id);
        get.setPhone(phone);
        get.setState(usestate);
        get.setUseDate(new Date());
        return getMapper.updateByPrimaryKeySelective(get);
    }

    @Override
    public List<Map<String, Object>> getUnusedList(String phone) {
        return getMapper.getUnusedList(phone);
    }

    @Override
    public List<Map<String, Object>> getusedList(String phone) {
        return getMapper.getusedList(phone);
    }

    @Override
    public List<Map<String, Object>> expiredList(String phone) {
        return getMapper.expiredList(phone);
    }
}
